package com.tedu.dao;

import com.tedu.pojo.News;
import com.tedu.pojo.Topic;

import java.util.List;

/**
 * 新闻类   型   dao
 */
public class NewsTopicDao extends BaseDao {

    /**
     * 获取全部的新闻类型
     * @return
     */
    public List<Topic> getAllTopic(){
        List<Topic> query = query(Topic.class, "SELECT * FROM topic");
        return query;
    }

    /**
     * 通过tid获取新闻列表
     * @param tid
     * @return
     */
    public List<News> getNewsByTID(String tid) {
        String sql = "SELECT * FROM news WHERE ntid = ?";
        List<News> query = query(News.class, sql, tid);
        return query;
    }

    /**
     * 获取 一条新闻记录
     * @param nid
     * @return
     */
    public List<News> getNewsById(String nid) {
        String sql = "SELECT * FROM news WHERE nid = ? ";
        return query(News.class,sql,nid);
    }
}
